package com.xiaoshuidi.cloud.module.rooms.enums;

import cn.hutool.core.lang.Assert;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

/**
 * 预定退定原因枚举
 * @author Joey
 */
@Getter
@AllArgsConstructor
public enum ReserveWithdrawReasonEnum {
    /**
     * 违约退定
     */
    DEFAULT(1,"违约退定"),
    /**
     * 协商退定
     */
    NEGOTIATE(2,"协商退定")
    ;
    private Integer value;
    private String name;

    public static Integer getValueByName(String name) {
        ReserveWithdrawReasonEnum resonEnum = Arrays.stream(ReserveWithdrawReasonEnum.values()).filter(p -> p.name.equals(name)).findFirst().orElse(null);
        Assert.isTrue(resonEnum != null,"ReserveWithdrawReasonEnum类型:{}不存在",name);
        return resonEnum.getValue();
    }

    public static String getNameByValue(Integer value) {
        ReserveWithdrawReasonEnum resonEnum = Arrays.stream(ReserveWithdrawReasonEnum.values()).filter(p -> p.value.equals(value)).findFirst().orElse(null);
        Assert.isTrue(resonEnum != null,"ReserveWithdrawReasonEnum类型:{}不存在",value);
        return resonEnum.getName();
    }

}
